package org.openintents.droidcon.cloud.mvc;

import org.openintents.droidcon.cloud.model.Panel;
import org.openintents.droidcon.cloud.model.Room;
import org.openintents.droidcon.cloud.model.Schedule;

public class PanelForm {

	private Panel editPanel = null;
	private Schedule schedule = null;

	public PanelForm(Schedule schedule, Panel editPanel) {
		if (editPanel != null) {
			this.editPanel = editPanel;
		}
		if (schedule != null) {
			this.schedule = schedule;
		}
	}

	public String display() {
		if (schedule != null) {
			String output = "<form action=\"/droidconcloud/schedule\" method=\"post\">"
					+ "<fieldset><legend>Panel</legend>"
					+ "<label for=\"from\">from:</label> "
					+ "<input type=\"text\" name=\"from\" id=\"from\" value=\""
					+ (editPanel != null ? editPanel.getFromString() : "")
					+ "\" /><br/>"
					+ "<label for=\"to\">to:</label> "
					+ "<input type=\"text\" name=\"to\" id=\"to\" value=\""
					+ (editPanel != null ? editPanel.getToString() : "")
					+ "\" />"
					+  "<input type=\"hidden\" name=\"id\" value=\""
							+ schedule.getId() + "\" />"							
					+ (editPanel != null ? "<input type=\"hidden\" name=\"panelId\" value=\""
							+ editPanel.getId().getId() + "\" />"
							: "")
					+ (editPanel == null ? "<input type=\"hidden\" name=\"action\" value=\"addPanel\" />"
							: "")
					+ (editPanel != null ? "<input type=\"hidden\" name=\"action\" value=\"editPanel\" />"
							: "")
					+ "<input type=\"submit\" value=\""
					+ (editPanel != null ? "edit" : "add")
					+ " panel\" /> "
					+ "<input type=\"submit\" name=\"action\" value=\"reset\" />"
					+ "</fieldset>" + "</form>";
			return output;
		} else {
			return "";
		}
	}

}
